package com.sanpu.kxe.business.login.view;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.sanpu.kxe.R;
import com.sanpu.kxe.utils.IntentTool;

/**
 * Description：欢迎页fragment
 * Created by 薛勇军 on 2018/6/12.
 */

public class ScreenSlideFragment extends Fragment {

    public ScreenSlideFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        Bundle args = getArguments();
        int position = args.getInt("position");

        ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.view_welcome, container, false);
        ImageView showIv = (ImageView) rootView.findViewById(R.id.welcome_bg);
        ImageView skipIv = (ImageView) rootView.findViewById(R.id.skipIv);
        skipIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                IntentTool.startActivity(getContext(), LoginActivity.class, true);
            }
        });
        showIv.setBackgroundResource(getDrawableId(position));
        return rootView;
    }

    private int getDrawableId(int position) {
        int id = 0;
        if (position == 0) {
            id = R.drawable.welcome_bg_one;
        } else if (position == 1) {
            id = R.drawable.welcome_bg_two;
        }
//        else if (position == 2) {
//            id = R.drawable.welcome_bg_three;
//        } else if (position == 3) {
//            id = R.drawable.welcome_bg_four;
//        }
        return id;
    }

//    @Override
//    public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                             Bundle savedInstanceState) {
//        Bundle args = getArguments();
//        int position = args.getInt("position");
//        int layoutId = getLayoutId(position);
//
//        ViewGroup rootView = (ViewGroup) inflater.inflate(layoutId, container, false);
//        return rootView;
//    }
//
//    private int getLayoutId(int position) {
//        int id = 0;
//        if (position == 0) {
//            id = R.layout.welcome_first_screen;
//        } else if (position == 1) {
//            id = R.layout.welcome_second_screen;
//        } else if (position == 2) {
//            id = R.layout.welcome_third_screen;
//        } else if (position == 3) {
//            id = R.layout.welcome_four_screen;
//        }
//        return id;
//    }
}
